<div class="popup_body">
    <div class="ui_table">
        <form method="post">
            <input type="hidden" name="portrait" id="portrait_${pid}">
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td width="70" align="right">登录名称：</td>
                    <td><input type="text" name="username" maxlength="40" class="text easyui-validatebox"
                               required="true" validType="unique[]"/></td>
                    <td width="70" align="right" valign="top" rowspan="2" style="padding-top:10px;">头像：</td>
                    <td rowspan="2">
                        <div class="portrait">
                            <a href="javascript:void(0)"><img id="image_${pid}" src="${app.imagePath}/user.jpg"/><span>修改头像</span></a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td align="right">姓名：</td>
                    <td><input type="text" maxlength="10" class="text" name="realName"/></td>
                </tr>
                <tr>
                    <td align="right">密码：</td>
                    <td><input type="password" maxlength="40" class="text" name="password"
                               id="password_${pid}" required="true"/></td>
                    <td align="right">确认密码：</td>
                    <td><input type="password" maxlength="40" class="text" name="password2"
                               required="true" validType="equals['#password_${pid}']"/></td>
                </tr>
                <tr>
                    <td align="right">启用：</td>
                    <td>
                            <span class="radio_box">
                                <input type="radio" class="radio" name="activeFlag" id="active_flag_1" checked
                                       value="1"/><label for="active_flag_1">启用</label>
                            </span>
                        <span class="radio_box">
                                <input type="radio" class="radio" name="activeFlag" id="active_flag_0" value="0"/><label
                                for="active_flag_0">禁用</label>
                            </span>
                    </td>
                    <td align="right">邮件：</td>
                    <td><input type="text" class="text" name="mail" maxlength="20"/></td>
                </tr>

                <tr>
                    <td align="right">电话号码：</td>
                    <td><input type="text" class="text easyui-validatebox" maxlength="17" class="text" name="tel"/></td>
                    <td align="right">手机号码：</td>
                    <td><input type="text" class="text easyui-validatebox" maxlength="11" class="text" name="mobile"
                               validType="mobile[]"/></td>
                </tr>
            <tr>
            <#if addFlag=='supplier'>
                <td align="right">厂商：</td>
                <td>
                    <input name="supplierId" class="easyui-combotree" editable="false"
                           style="width: 184px; height: 28px;" id="supplier_id_${pid}" required
                           data-options="url:'${contextPath}/security/hdw/supplier/tree.htm',method:'get'"/>
                </td>
            <#else>
            </tr>
                <tr>
                    <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
                        <td align="right">运营商：</td>
                        <td>
                            <input name="agentId" class="easyui-combotree" editable="false"
                                   style="width: 184px; height: 28px;" id="agent_id_${pid}" required
                                   data-options="url:'${contextPath}/security/basic/agent/tree.htm',method:'get',onSelect: function(rec){
                               var url = '${contextPath}/security/hdw/agency/tree.htm?agentId='+rec.id;
                               var url1 = '${contextPath}/security/basic/role/find_all.htm?agentId='+rec.id;
                               var url2 = '${contextPath}/security/basic/dept/tree.htm?agentId='+rec.id;
                               $('#agency_id_${pid}').combotree('reload', url);
                               $('#role_id_${pid}').combotree('reload', url1);
                               $('#dept_id_${pid}').combotree('reload', url2);},
                               onChange:function(){
                                $('#agency_id_${pid}').combotree('clear');
                                $('#role_id_${pid}').combotree('clear');
                                $('#dept_id_${pid}').combotree('clear');}"/>
                        </td><#else>
                        <input type="hidden" name="agentId" value="${Session['SESSION_KEY_USER'].agentId}"></#if>
                    <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENT'].value||Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
                        <td align="right">代理商：</td>
                        <td>
                            <input name="agencyId" class="easyui-combotree" editable="false"
                                   style="width: 184px; height: 28px;" id="agency_id_${pid}"
                                   data-options="url:'${contextPath}/security/hdw/agency/tree.htm?agentId=${Session['SESSION_KEY_USER'].agentId}'"/>
                        </td><#else><input type="hidden" name="agencyId"
                                           value="${Session['SESSION_KEY_USER'].agencyId}"></#if>
                </tr>
                <tr>
                    <td align="right">角色：</td>
                    <td>
                        <input class="easyui-combotree" name="roleId" id="role_id_${pid}" required="true"
                               editable="false" style="width: 184px; height: 28px;"
                               data-options="url:'${contextPath}/security/basic/role/find_all.htm?agentId=${Session['SESSION_KEY_USER'].agentId}'">
                    </td>
                    <td align="right">部门：</td>
                    <td>
                        <input name="deptId" class="easyui-combotree" editable="false" required="required"
                               style="width: 184px; height: 28px;"
                               id="dept_id_${pid}"
                               data-options="url:'${contextPath}/security/basic/dept/tree.htm?agentId=${Session['SESSION_KEY_USER'].agentId}'"/>
                    </td>
                </tr>
            </#if>
                <tr>
                    <td align="right">管理员：</td>
                    <td>
                            <span class="radio_box">
                                <input type="radio" class="radio" name="adminFlag" id="admin_flag_1" checked value="1"/><label
                                    for="admin_flag_1">是</label>
                            </span>
                        <span class="radio_box">
                                <input type="radio" class="radio" name="adminFlag" id="admin_flag_0" value="0"/><label
                                for="admin_flag_0">否</label>
                            </span>
                    </td>
                    <td align="right">备注：</td>
                    <td><input type="text" class="text" name="memo" maxlength="20"/></td>
                </tr>
            </table>
        </form>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_red ok">确定</button>
    <button class="btn btn_border close">关闭</button>
</div>
<script>
    function set_portrait(param) {
        $('#image_${pid}').attr('src', '${contextPath}' + param.filePath);
        $('#portrait_${pid}').val(param.filePath);
        $('#' + param.pid).window('close');
    }

    (function () {
        var pid = '${pid}',
                win = $('#' + pid),
                form = win.find('form');

        win.find('button.ok').click(function () {
            form.form('submit', {
                url: '${contextPath}/security/basic/user/create.htm',
                success: function (text) {
                    var json = $.evalJSON(text);
                <@app.json_jump/>
                    if (json.success) {
                        $.messager.alert('提示信息', '操作成功', 'info');
                        win.window('close');
                    } else {
                        $.messager.alert('提示信息', json.message, 'info');
                    }
                }
            });
        });
        win.find('button.close').click(function () {
            win.window('close');
        });
        win.find('.portrait').click(function () {
            App.dialog.show({
                css: 'width:558px;height:150px;overflow:visible;',
                title: '上传头像',
                href: "${contextPath}/security/main/portrait.htm",
                windowData: {
                    staticUrl: '${contextPath}/security/main/portrait.htm'
                },
                event: {
                    onClose: function () {
                    }
                }
            });
        });

    })()
</script>